package com.woniuxy.controller;


import com.woniuxy.entitys.TbHospital;
import com.woniuxy.service.HospitalService;
import com.woniuxy.utils.ResultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @Classname HospitalController
 * @Date 2024/1/11 16:59
 */
@RestController
public class HospitalController {

    @Autowired
    private HospitalService hospitalService;
    @GetMapping("/hospital/getAllHospital")
    public ResultVO getAllHospital(){
        List<TbHospital> allHospital = hospitalService.getAllHospital();
        return allHospital!=null?ResultVO.success("医院查询成功",allHospital):ResultVO.failure("医院查询失败");
    }

    @GetMapping("/hospital/getallHospital")
    public ResultVO getallHospital(){
        int i = hospitalService.getallHospital();
        return i>=0?ResultVO.success("医院查询成功",i):ResultVO.failure("医院查询失败");
    }
    @GetMapping("/hospitalList")
    public ResultVO getHospitalList(){
        List<TbHospital> allHospital = hospitalService.getAllHospital();
        return allHospital!=null?ResultVO.success("医院查询成功",allHospital):ResultVO.failure("医院查询失败");
    }

    /*
    *级联查询数据
    * */
    @GetMapping("/hospital/list")
    public ResultVO getAllHospitalList(){
        List<TbHospital> hospitalList = hospitalService.getHospitalList();
        return hospitalList!=null?ResultVO.success("医院查询成功",hospitalList):ResultVO.failure("医院查询失败");
    }
    /**
     * 查询所有医院和其对应的科室(树结构)
     * @return
     */
    @GetMapping("/hospital/getHospitalAndDepartment")
    public ResultVO getHospitalAndDepartment(){
        List<TbHospital> allHospital = hospitalService.getHospitalAndDepartment();
        return allHospital!=null?ResultVO.success("医院查询成功",allHospital):ResultVO.failure("医院查询失败");
    }
}
